package com.daogu.fuelcard.controller;

import com.daogu.fuelcard.entity.RequestRecord;
import com.daogu.fuelcard.service.RequestRecordService;
import com.daogu.fuelcard.utils.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;

@Controller
@Tag(name = "请款记录控制器")
public class RequestRecordController {

    @Autowired
    private RequestRecordService requestRecordService;

    @PostMapping("/insertRequestRecord")
    @ResponseBody
    @Operation(description = "新增请款记录")
    public Result<Void> insert(RequestRecord requestRecord) {
        return requestRecordService.insert(requestRecord);
    }


    @PostMapping("/requestRecord/deletedById")
    @ResponseBody
    @Operation(description = "删除请款记录")
    public Result<Void> deletedById(@RequestParam Integer id) {
        return requestRecordService.deletedById(id);
    }

    @PostMapping("/updateWriteOffAmount")
    @ResponseBody
    @Operation(description = "核销")
    public Result<Void> updateWriteOffAmount(@RequestParam Integer id) {
        return requestRecordService.updateWriteOffAmount(id);
    }

    @GetMapping("/getRequestRecords")
    @ResponseBody
    @Operation(description = "获取请款记录")
    public Result<PageInfo<RequestRecord>> getRequestRecords(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
        return requestRecordService.getRequestRecord(pageNum,pageSize);
    }

    @Operation(description = "请款页面")
    @GetMapping("/request")
    public String login() {
        return "request";
    }

}
